<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"    
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <!-- INTERFACE -->
    <cc:interface>      
        <cc:attribute name="bill" />           
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:outputStylesheet library="css" name="printing.css" />
        <div  >
            <p:panel   id="gpBillPreview"  style="margin: auto; padding: 0px; " >
                <div class="a4bill" >


                    <table class="heading" >
                        <tr>
                            <td colspan="4">
                                <h:outputLabel class="mark" value="**Intrim Bill**" />
                            </td>
                        </tr>
                    </table>
                    <table>
                        <tr >
                            <td >
                                <h:outputLabel value="Patient Name : " />
                            </td>
                            <td >
                                <h:outputLabel value="#{cc.attrs.bill.patientEncounter.patient.person.nameWithTitle}" />
                            </td>                           
                        </tr>

                        <tr >
                            <td >
                                <h:outputLabel value="Guardian : " />
                            </td>
                            <td >
                                <h:outputLabel value="#{cc.attrs.bill.patientEncounter.guardian.nameWithTitle}" />
                            </td>                           
                        </tr>

                        <tr>
                            <td >
                                <h:outputLabel value="Address : " />
                            </td>
                            <td >
                                <h:outputLabel value="#{cc.attrs.bill.patientEncounter.patient.person.address}" />
                            </td>                           
                        </tr>

                        <tr >
                            <td >
                                <h:outputLabel value="BHT : " />
                            </td>
                            <td >
                                <h:outputLabel value="#{cc.attrs.bill.patientEncounter.bhtNo}" />
                            </td>    

                        </tr>

                        <tr >
                            <td >
                                <h:outputLabel value="Room : " />
                            </td>
                            <td >
                                <h:outputLabel value="#{cc.attrs.bill.patientEncounter.currentPatientRoom.roomFacilityCharge.room.name}"/>
                            </td>    

                        </tr>

                        <tr>
                            <td >
                                <h:outputLabel value="Time of Admission : " />
                            </td>
                            <td >
                                <h:outputLabel value="#{cc.attrs.bill.patientEncounter.dateOfAdmission}" >
                                    <f:convertDateTime pattern="dd MM yyyy h:mm a" />
                                </h:outputLabel>
                            </td>
                        </tr>
                        <tr>
                            <td >
                                <h:outputLabel value="Time of Discharged : " />
                            </td>
                            <td >
                                <h:outputLabel value="#{cc.attrs.bill.patientEncounter.dateOfDischarge}" >
                                    <f:convertDateTime pattern="dd MM yyyy h:mm a" />
                                </h:outputLabel>
                            </td>
                        </tr>                        


                    </table>

                    <table class="tbl"  >
                        <ui:repeat value="#{cc.attrs.bill.billItems}" var="bip">
                            <h:panelGroup rendered="#{bip.adjustedValue !=0}">
                                <tr>

                                    <td style="text-align: left;" >
                                        <h:outputLabel  value="#{bip.inwardChargeType.label}" />
                                    </td>                                   
                                    <td style="text-align: right;" >
                                        <h:outputLabel value="#{bip.adjustedValue}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>  
                                    </td>

                                </tr>
                            </h:panelGroup>
                        </ui:repeat>

                        <h:panelGroup>
                            <tr>   
                                <td>&nbsp;</td>
                                <td style="text-align: right;"><h:outputLabel value="-------------------" /></td>
                            </tr>
                            <tr style="width: 100%;">
                                <td style="text-align: left; font-size: 13px!important;font-weight: bold!important;">
                                    <h:outputLabel value="Total"/>
                                </td>                               
                                <td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                    <h:outputLabel  value="#{cc.attrs.bill.total}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>  

                                </td>
                            </tr>

                        </h:panelGroup>


                        <h:panelGroup>
                            <tr>
                                <td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                    <h:outputLabel   value="Paid By Patient" />
                                </td>                              
                                <td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                    <h:outputLabel value="#{cc.attrs.bill.paidAmount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>                            
                                </td>
                            </tr>
                        </h:panelGroup>

                        <h:panelGroup>
                            <tr>                
                                <td>&nbsp;</td>
                                <td style="text-align: right;"><h:outputLabel value="-------------------" /></td>
                            </tr>
                            <tr>
                                <td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                    <h:outputLabel value="Due" />   
                                </td>

                                <td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                    <h:outputLabel id="due" value="#{cc.attrs.bill.total-cc.attrs.bill.paidAmount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </td>
                            </tr>
                            <tr>    
                                <td>&nbsp;</td>
                                <td style="text-align: right;"><h:outputLabel value="==========="/></td>
                            </tr>

                        </h:panelGroup>
                    </table>

                    <p:spacer height="50px"></p:spacer>

                    <h:outputLabel value="Cashier : #{cc.attrs.bill.creater.code}">
                    </h:outputLabel>

                    <h:outputLabel value="     Patient/Guardian     " style="margin-left: 60%; text-decoration: overline;">
                    </h:outputLabel>


                </div>


            </p:panel>
        </div>
    </cc:implementation>
</html>